package com.demo.web.security;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

//用户配置文件 基于内存的用户管理
//声明配置文件
//全局方法安全验证注入
@EnableGlobalMethodSecurity(prePostEnabled = true)//预授权和后授权
public class MySecurityUser {

    //用户详情接口服务
//    @Bean
//    public UserDetailsService userDetailsService(){
//        UserDetails user1= User.builder().username("student").password(passwordEncoder().encode("123456")).roles("student").build();//ROLE_Student
//        UserDetails user2= User.builder().username("boy").password(passwordEncoder().encode("123456")).authorities("boy:add","boy:query","boy:del","boy:update")  .build();
//        InMemoryUserDetailsManager manager=new InMemoryUserDetailsManager();
//        manager.createUser(user1);
//        manager.createUser(user2);
//        return manager;
//    }


}
